package com.person.jiaiplan.controller;

import com.person.jiaiplan.pojo.R;
import com.person.jiaiplan.pojo.dto.calendar.CalendarQueryResDTO;
import com.person.jiaiplan.pojo.dto.calendar.CommemorationDayResDTO;
import com.person.jiaiplan.pojo.entity.SchedulePlanLogs;
import com.person.jiaiplan.service.JiAiCalendarService;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 计划日历
 */
@AllArgsConstructor
@RestController
@RequestMapping("calendar/")
@Validated
public class JiAiCalendarController {

    @Autowired
    private JiAiCalendarService jiAiCalendarService;

    /**
     * 根据日历时间查询当日数据
     * @param dateTime
     * @return
     */
    @GetMapping("/query/one")
    public R<CalendarQueryResDTO> queryByScheduleId(@RequestParam(name = "dateTime") String dateTime) {
        return R.ok(jiAiCalendarService.queryCalendarByDay(dateTime));
    }

    /**
     * 添加纪念日
     * @param resDTO
     * @return
     */
    @PostMapping("/add/commemoration")
    public R<Boolean> addCommemorationDay(@RequestBody CommemorationDayResDTO resDTO){
        return R.ok(jiAiCalendarService.addCommemorationDay(resDTO));
    }

    @GetMapping("/get/commemoration")
    public R<List<CommemorationDayResDTO>> getCommemorationDay(@RequestParam(name = "dateTime") String dateTime,@RequestParam(name = "type") String type) {
        return R.ok(jiAiCalendarService.getCommemorationDay(dateTime,type));
    }


}
